﻿using System;
using System.Linq.Expressions;

namespace Marketplace.Engine.Repository.Generic
{
    public class ListCondition<T>
    {
        public ListCondition(Expression<Func<T, bool>> filter) : this(filter, null, 20, 0)
        {
            Filter = filter;
            IsPagingEnabled = false;
        }

        public ListCondition(Expression<Func<T, bool>> filter, Expression<Func<T, string>> orderBy, uint pageSize, uint pageNumber)
        {
            Filter = filter;
            OrderBy = orderBy;

            if (pageSize > 0)
                IsPagingEnabled = false; 

            PageSize = pageSize;
            PageNumber = pageNumber > 0 ? pageNumber : 0;
        }

        public Expression<Func<T, bool>> Filter { get; set; }
        public Expression<Func<T, string>> OrderBy { get; set; }
        public string IncludeProperties { get; set; }

        public bool IsPagingEnabled { get; set; }
        public uint PageSize { get; set; }
        public uint PageNumber { get; set; }
    }
}